﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

using ERP_RORZE_PERMISSION.Base;
using ERP_RORZE_PERMISSION.Forms;

namespace ERP_RORZE_DLL.Assembly
{
    public partial class AssemblyLeftPannel : UserControl
    {
        private Permission role;

        public AssemblyLeftPannel()
        {
            InitializeComponent();
            this.role = new Permission();
            ShowHideLink();
        }

        ///////////////////////////////////////////
        /// Check role
        ///////////////////////////////////////////
        private void ShowHideLink()
        {
            if (role.Is_Login())
            {
                //if (role.HasNotRight(PermissionConstants.Functions.Tab.System))
                //    systemTab.Visible = false;

                if (role.HasNotRight(PermissionConstants.Functions.Assembly.F5ControlPlanning))
                    navF5AssemblyPlanning.Visible = false;

                if (role.HasNotRight(PermissionConstants.Functions.Assembly.F5ControlWTS))
                    navF5AssemblyWTS.Visible = false;

                if (role.HasNotRight(PermissionConstants.Functions.Assembly.F5Search))
                    navF5Search.Visible = false;

                if (role.HasNotRight(PermissionConstants.Functions.Assembly.F5LocalError))
                    navF5LocalError.Visible = false;

                if (role.HasNotRight(PermissionConstants.Functions.Assembly.F5ExportError))
                    navF5ExportError.Visible = false;

                if (role.HasNotRight(PermissionConstants.Functions.Assembly.F4Comp))
                    navF4Part.Visible = false;

                if (role.HasNotRight(PermissionConstants.Functions.Assembly.F4SerialInput))
                    navSerialInput.Visible = false;

                if (role.HasNotRight(PermissionConstants.Functions.Assembly.F4AssemblyPlanning))
                    navF4AssemblyPlanning.Visible = false;

                if (role.HasNotRight(PermissionConstants.Functions.Assembly.F4AssemblyWTS))
                    navF4AssemblyWTS.Visible = false;

                if (role.HasNotRight(PermissionConstants.Functions.Assembly.F4AssemblyExport))
                    navF4AssemblyExport.Visible = false;

                if (role.HasNotRight(PermissionConstants.Functions.Assembly.F4AssemblyPrint))
                    navPrintData.Visible = false;

                if (role.HasNotRight(PermissionConstants.Functions.Assembly.F4AssemblyCheck))
                {
                    navF4CheckFORS300.Visible = false;
                    navF4CheckFORS300.Visible = false;
                    navF4CheckFORS300.Visible = false;
                    navF4CheckFORS300.Visible = false;
                    navF4CheckFORS300.Visible = false;
                    navF4CheckFORS300.Visible = false;
                }

                if (role.HasNotRight(PermissionConstants.Functions.Assembly.F4LocalError))
                    navF4LocalError.Visible = false;

                if (role.HasNotRight(PermissionConstants.Functions.Assembly.F4ExportError))
                    navF4ExportError.Visible = false;

                if (role.HasNotRight(PermissionConstants.Functions.Assembly.MaterialKosei))
                    navMaterialKosei.Visible = false;

                if (role.HasNotRight(PermissionConstants.Functions.Assembly.MaterialOrder))
                    navMaterialOrder.Visible = false;

                if (role.HasNotRight(PermissionConstants.Functions.Assembly.MaterialImport))
                    navMaterialImport.Visible = false;

                if (role.HasNotRight(PermissionConstants.Functions.Assembly.MaterialExport))
                    navMaterialExport.Visible = false;

                if (role.HasNotRight(PermissionConstants.Functions.Assembly.F5Yoyaku))
                    navPlan.Visible = false;

                if (role.HasNotRight(PermissionConstants.Functions.Assembly.AssemblyReport))
                {
                    navF5Producing.Visible = false;
                    navF5ProductDetails.Visible = false;
                    //navF5TimeDaily.Visible = false;
                    navF5TimeMonthly.Visible = false;
                    navF5DirectIndirect.Visible = false;
                    navF5TimeReport.Visible = false;
                    navF4MaterialLoss.Visible = false;
                    navF4Producing.Visible = false;
                    //navF4ProductDetails.Visible = false;
                    //navF4TimeDaily.Visible = false;
                    navF4TimeMonthly.Visible = false;
                    //navF4TimeDirectIndirect.Visible = false;
                    navF4TimeReport.Visible = false;
                    navInspection.Visible = false;
                    navStampPrint.Visible = false;
                    navLocalErrorSummary.Visible = false;
                    navExportErrorSummary.Visible = false;
                }

                if (role.HasNotRight(PermissionConstants.Functions.Assembly.MaterialKosei))
                    navMaterialKosei.Visible = false;
                if (role.HasNotRight(PermissionConstants.Functions.Assembly.MaterialImportPlan))
                    navMaterialImportPlan.Visible = false;
                if (role.HasNotRight(PermissionConstants.Functions.Assembly.MaterialExportPlan))
                    navMaterialExportPlan.Visible = false;
            }
            else
            {
                foreach (Control c in this.Controls)
                {
                    if (c is DevExpress.XtraNavBar.NavBarControl)
                    {
                        foreach (DevExpress.XtraNavBar.NavBarItem sub_c in c.Controls)
                        {
                            ((DevExpress.XtraNavBar.NavBarItem)sub_c).Enabled = false;
                        }
                    }
                }
            }
        }        
    }
}
